package org.xiaobai.ai.controller;

import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.xiaobai.common.request.LoginRequest;
import org.xiaobai.common.service.SysUserService;
import org.xiaobai.core.config.ChatConfig;
import org.xiaobai.tool.response.Result;

@Api(value = "key", tags = {"key"})
@CrossOrigin
@RestController
@RequestMapping("/")
@Validated
public class KeyController {

    @Autowired
    private SysUserService sysUserService;

    @Autowired
    private ChatConfig chatConfig;
    /**
     * apiKey
     */
    @PostMapping("/apiKey")
    public Result<String> listByModel(@RequestBody LoginRequest loginRequest) {
        sysUserService.login(loginRequest);
        return Result.success(chatConfig.getOpenaiApiKey());
    }
}
